/*
 * amplitude_scrambling.h
 *
 *  Created on: Apr 12, 2011
 *      Author: Paul Woelfel
 */

#ifndef AMPLITUDE_SCRAMBLING_H_
#define AMPLITUDE_SCRAMBLING_H_

#include "crypto_engine.h"

class CAmplitudeScrambling: public CCryptoEngine {
public:
	CAmplitudeScrambling(NAudioFormats::SStreamInfo ioStreamInfo);

	virtual ~CAmplitudeScrambling();

	/**
	 * abstract method encrypt
	 * encrypt pCount bytes from data and write them back to data
	 * if not enough data is available for encryption, zeros should
	 * be written to the data buffer
	 * @param data double array with amplitude values from 0 to 1
	 * @param pCount count of audio samples to work with
	 * @return 0 for success, >0 for success and discard of samples for next
	 *         call, <0 for an error
	 */
	virtual int encrypt(double *pData, unsigned int pCount);

	/**
	 * abstract method decrypt
	 * decrypt pCount bytes from data and write them back to data
	 * if not enough data is available for decryption, zeros should
	 * be written to the data buffer
	 * @param data double array with amplitude values from 0 to 1
	 * @param pCount count of audio samples to work with
	 * @return 0 for success, >0 for success and discard of samples for next
	 *         call, <0 for an error
	 */
	virtual int decrypt(double *pData, unsigned int pCount);

protected:
	/**
	 * called by the protocol engine upon settings change
	 * (e.g. change of embedding parameters)
	 * calls setProperties and initCrypto
	 * if this method gets overwritten, the subclass should call
	 * setProperties and initCrypto
	 */
	virtual int changeSettings();

	/**
	 * encrypt or decrypt some bytes
	 * Encryption and decryption is the same algorithm, just plus or minus. One method does it all
	 */
	int dencrypt(double * pData, unsigned int pCount, bool encrypt);

private:
	static const std::string sIniSectionName;
};

#endif /* AMPLITUDE_SCRAMBLING_H_ */
